<template>
  <div class="infos">
    <div class="name">{{ topModule.houseName }}</div>
    <div class="tags">
      <template v-for="(item, index) in topModule.houseTags" :key="index">
        <span
          class="item"
          v-if="item.tagText"
          :style="{ color: item.tagText.color, background: item.tagText.background.color }"
        >
          {{ item.tagText.text }}
        </span>
      </template>
    </div>
    <div class="comment">
      <div class="left">
        <span class="score">
          <span>
            {{ number2 }}
          </span>
        </span>
        <span class="title">{{ topModule.commentBrief.scoreTitle }}</span>
        <span class="brief">"{{ topModule.commentBrief.commentBrief }}"</span>
      </div>
      <div class="right">
        <span class="Count">
          {{ topModule.commentBrief.totalCount }}条评论<van-icon name="arrow" />
        </span>
      </div>
    </div>
    <div class="location comment">
      <div class="left">
        {{ topModule.nearByPosition.address }}
      </div>
      <div class="right">地图·周边<van-icon name="arrow" /></div>
    </div>
  </div>
</template>

<script setup>
  import { ref } from 'vue'
  const props = defineProps({
    topModule: {
      type: Object,
      default: () => ({})
    }
  })

  // 判断评分 如果为一位数加.0
  const number = ref(String(props.topModule.commentBrief.overall))
  const number2 = ref()
  if (number.value.length == 1) {
    number2.value = number.value.charAt(0, 1) + '.0'
  } else {
    number2.value = props.topModule.commentBrief.overall
  }
</script>

<style scoped>
  .infos {
    padding: 16px;
    background-color: #fff;
  }
  .name {
    font-weight: 700;
    font-size: 20px;
    color: #333;
    text-align: justify;
    line-height: 24px;
    overflow: hidden;
    margin-bottom: 6px;
  }
  .tags {
    font-size: 12px;
    margin: 10px 0;
  }
  .item {
    font-size: 12px;
    margin: 0 2px;
    padding: 2px 3px;
  }
  .comment {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin: 12px 0;
    border-radius: 5px;
    font-size: 12px;
    background-color: #f5f7fa;
  }
  .brief {
    font-size: 8px;
    font-weight: 700;
    color: #666;
  }
  .left {
    font-size: 15px;
    font-weight: 700;
  }
  .right {
    color: #ff9645;
  }
  .score {
    font-size: 20px;
    font-weight: 600;
  }
  .title {
    font-size: 13px;
  }
</style>
